home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / BSP Tree 1.2 / Sources / Graphics / source / tuple_2d.cp < prev    next >
Encoding:
Text File  |  1995-03-25  |  3.7 KB  |  72 lines  |  [TEXT/MMCC]

  1. //------------------------------------------------------------------------------
  2. //    File:                    tuple_2d.cp
  3. //    Date:                    8/26/94
  4. //    Author:                Bretton Wade
  5. //
  6. //    Description:    this file contains the methods for a tuple_2d
  7. //
  8. //------------------------------------------------------------------------------
  9.  
  10. #include "utility.h"
  11. #include "tuple_2d.h"
  12.  
  13. //------------------------------------------------------------------------------
  14. //    constructor
  15. //------------------------------------------------------------------------------
  16. tuple_2d::tuple_2d (const tuple_2d &t)                                                                                    //    copy constructor
  17. {                                                                                                                                                                //    begin
  18.     xy[X] = t[X]; xy[Y] = t[Y];                                                                                                        //    copy the values into the tuple_2d
  19. }                                                                                                                                                                //    end
  20.  
  21. //------------------------------------------------------------------------------
  22. //    constructor
  23. //------------------------------------------------------------------------------
  24. tuple_2d::tuple_2d (real x, real y)                                                                                            //    constructor from 2 values
  25. {                                                                                                                                                                //    begin
  26.     xy[X] = x; xy[Y] = y;                                                                                                                    //    copy the values into the tuple_2d
  27. }                                                                                                                                                                //    end
  28.  
  29. //------------------------------------------------------------------------------
  30. //    assignment operator
  31. //------------------------------------------------------------------------------
  32. void    tuple_2d::operator = (const tuple_2d &t)                                                                    //    assignment operator
  33. {                                                                                                                                                                //    begin
  34.     xy[X] = t[X]; xy[Y] = t[Y];                                                                                                        //    copy the values into the tuple_2d
  35. }                                                                                                                                                                //    end
  36.  
  37. //------------------------------------------------------------------------------
  38. //    equality test
  39. //------------------------------------------------------------------------------
  40. bool    tuple_2d::operator == (const tuple_2d &t) const                                                        //    equality operator
  41. {                                                                                                                                                                //    begin
  42.     return    bool ((abs (xy[X] - t[X]) < EPSILON) &&                                                             //    compare the x coordinates
  43.                                 (abs (xy[Y] - t[Y]) < EPSILON));                                                                //    compare the w coordinates            
  44. }                                                                                                                                                                //    end
  45.  
  46. //------------------------------------------------------------------------------
  47. //    inequality test
  48. //------------------------------------------------------------------------------
  49. bool    tuple_2d::operator != (const tuple_2d &t) const                                                        //    inequality operator
  50. {                                                                                                                                                                //    begin
  51.     return    bool ((abs (xy[X] - t[X]) > EPSILON) ||                                                             //    compare the x coordinates
  52.                                 (abs (xy[Y] - t[Y]) > EPSILON));                                                                //    compare the w coordinates            
  53. }                                                                                                                                                                //    end
  54.  
  55. //------------------------------------------------------------------------------
  56. //    assignment
  57. //------------------------------------------------------------------------------
  58. void    tuple_2d::operator () (real x, real y)                                                                        //    function call operator
  59. {                                                                                                                                                                //    begin
  60.     xy[X] = x; xy[Y] = y;                                                                                                                    //    copy the values into the tuple_2d
  61. }                                                                                                                                                                //    end
  62.  
  63. //------------------------------------------------------------------------------
  64. //    dot product
  65. //------------------------------------------------------------------------------
  66. real    tuple_2d::operator | (const tuple_2d &t) const                                                        //    inner product operator
  67. {                                                                                                                                                                //    begin
  68.     return     (xy[X] * t[X]) + (xy[Y] * t[Y]);                                                                            //    coordinate multiply
  69. }                                                                                                                                                                //    end
  70.  
  71. //------------------------------------------------------------------------------
  72.